package com.xy.utils;

import com.xy.exception.ErrorEnum;
import com.xy.exception.ServiceException;


public class ResponseFactory<T>  {
    private static final int OK_CODE = 0;

    private ResponseFactory() {
    }

    public static <T> Response<T> okResponse(Object data) {
        return new Response(OK_CODE, data);
    }

    public static Response<String> errResponse(int errCode, String errMessage) {
        return new Response(errCode, errMessage);
    }

    public static Response<String> errResponse(ErrorEnum response) {
        return new Response(response.getErrCode(), response.getErrMessage());
    }

    public static Response<String> errResponse(ServiceException e){
        return new Response(e.getErrCode(),e.getMessage());
    }
}
